/**
 * 
 */
package com.fox.webapp.persistent;

import java.util.List;

import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.fox.webapp.domain.Person;
import com.fox.webapp.persistent.custom.PersonRepositoryCustom;

/**
 * @author yockii
 *
 */
public interface PersonRepository extends PagingAndSortingRepository<Person, ObjectId>, PersonRepositoryCustom {

//	@Query(value = "{$or:[{username:?0},{email:?1},{mobile:?2}]}")
//	Person isUsernameEmailMobileExist(String username, String email, String mobile);
	@Query(value = "{mobile:?0}")
	Person isMobileExist(String mobile);
	@Query(value = "{email:?0}")
	Person isEmailExist(String email);
	@Query(value = "{username:?0}")
	Person isUsernameExist(String username);
	@Query(value = "{$or:[{username:?0},{email:?0},{mobile:?0}]}")
	Person findByUsername(String username);
	
	Page<Person> findByUsernameOrEmailOrFirstNameOrLastNameOrMobileAllIgnoreCase(
			String username, String email, String firstName, String lastName,
			String mobile, Pageable pageRequest);
	
	List<Person> findByRegisterIp(String registerIp);
		
//	@Query(value = "{referenceId: ?0}", fields = "{username: 1}")
//	List<Person> findByReferenceId(String string, PageRequest pageRequest);
	
}
